<template>
	<view class="container">
		
		<uni-section title="借用单信息" type="line">
			<uni-list>
				<uni-list-item title="分类型号" :rightText="form.cate_name + ' ' + form.model_name"/>
				<uni-list-item title="借用数量" :rightText="form.amount + ' ' + form.unit"/>
				<uni-list-item title="申请时间" :rightText="form.apply_time"/>
				<uni-list-item title="申请人" :rightText="form.dept_name + ' ' + form.user_name"/>
				<uni-list-item title="申请原因" :note="form.reason"/>
				<uni-list-item title="借用说明" :note="form.remark" v-if="form.remark"/>
			</uni-list>
		</uni-section>
		
		<uni-section title="出库资产" type="line">
			<uni-list>
				<uni-list-item :title="a.num" :rightText="a.out_time" v-for="(a,i) in assetList" :key="i"/>
			</uni-list>
		</uni-section>
	</view>
</template>

<script>
	import { apiGet} from '@/api/openapi'

	export default {
		data() {
			return {
				useId: null,
				action: 'add',
				form: {},
				assetList: []
			}
		},
		onLoad(option) {
			this.useId = option.id;			
			this.getData();
		},
		methods: {
			getData(){
				let params = {
					"asset_use": {"@alias":"t", "id":this.useId},
					"asset_model": {"@alias":"m", "@column":"name:model_name,unit","@join":"m.id = t.model_id"},
					"asset_category":{"@alias":"c","@column":"name:cate_name","@join":"c.id = m.cate_id"}
				};
				apiGet(params).then(response => {
					this.form = response.data;
				})
				
				params = {
					"asset_use_detail":{"@alias":"t","use_id":this.useId},
					"asset_info": {"@alias":"i", "@column":"num","@join":"i.id = t.asset_id"},
					"@pager":{page:1,limit:10000}
				};
				apiGet(params).then(response => {
					this.assetList = response.data.rows;
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ffffff;
	}

	.example {
		padding: 15px;
		background-color: #fff;
	}

	.segmented-control {
		margin-bottom: 15px;
	}

	.button-group {
		margin-top: 15px;
		display: flex;
		justify-content: space-around;
	}

	.form-item {
		display: flex;
		align-items: center;
		flex: 1;
	}

	.button {
		display: flex;
		align-items: center;
		height: 35px;
		line-height: 35px;
		margin-left: 10px;
	}
</style>